{template 'common/header'}
{if $operation == 'display'}
<a href="{php echo $this->createWebUrl('banner',array('op' =>'post'))}" class="btn btn-success"><i class="fa fa-plus"></i> 添加轮播图</a>
<div class="main panel panel-default">
	<div class="panel-body table-responsive">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th style="width:30px;">ID</th>
					<th style="text-align: center;">显示顺序</th>					
					<th style="text-align: center;">图片名称</th>
					<th style="text-align: center;">图片</th>
					<th style="text-align: center;">跳转地址</th>
					<th style="text-align: center;">操作</th>
				</tr>
			</thead>
			<tbody>
				{loop $list $item}
				<tr>
					<td style="vertical-align: inherit;">{$item['id']}</td>
					<td style="text-align: center;vertical-align: inherit;">{$item['sort']}</td>
					<td style="text-align: center;vertical-align: inherit;">{$item['name']}</td>
					<td style="text-align: center;vertical-align: inherit;"><img width="100" src="{php echo tomedia($item['pic_img'])}" alt=" "></td>
					<td style="text-align: center;vertical-align: inherit;">{$item['url']}</td>
					<td style="text-align:center;font-size: 10px;vertical-align: inherit;">
						<a href="{php echo $this->createWebUrl('banner', array('op' => 'post', 'id' => $item['id']))}" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="修改"><i class="fa fa-edit"></i></a>
						<a href="{php echo $this->createWebUrl('banner', array('op' => 'delete', 'id' => $item['id']))}" onclick="return confirm('确认删除吗？');return false;" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="删除"><i class="fa fa-times"></i></a>
					</td>
				</tr>
				{/loop}
			</tbody>
		</table>
		{$pager}
	</div>
</div>
{elseif $operation == 'post'}
<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" onsubmit='return formcheck()'>
		<div class="panel panel-default">
			<div class="panel-heading">
				信息
			</div>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="sort" class="form-control" value="{$banner['sort']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>名称</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='name' name="name" class="form-control" value="{$banner['name']}" />
					</div>
				</div>
				<div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">图片</label>
                    <div class="col-sm-9 col-xs-12">
                        {php echo tpl_form_field_image('pic_img', $banner['pic_img'])}
						<span class="help-block">图片推荐大小：250px * 200px</span>
                    </div>
                </div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>跳转地址</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='url' name="url" class="form-control" value="{$banner['url']}" />
					</div>
				</div>
            </div>
		</div>
		<div class="form-group col-sm-12">
			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
			<input type="hidden" name="id" value="{$banner['id']}" />
			<input type="hidden" name="token" value="{$_W['token']}" />
		</div>
	</form>
</div>
<script language='javascript'>
	function formcheck() {
		if ($("#name").val() == '') {
			util.message("请输入名称");
			return false;
		}
		return true;
	}
</script>
{/if}

{template 'common/footer'}